package com.koocloud.electroplatemanage.controller;

import com.koocloud.electroplatemanage.common.pojo.ResponseTemplate;
import com.koocloud.electroplatemanage.pojo.Operate;
import com.koocloud.electroplatemanage.pojo.Tank;
import com.koocloud.electroplatemanage.pojo.TypeWorkVo;
import com.koocloud.electroplatemanage.service.OperateService;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program:
 * @description:镀槽操作单
 * @author: wjx
 * @create: 2020/11/18 17:07
 */
@RestController
@RequestMapping("/operate")
public class OperateController {
    static Logger log = Logger.getLogger("typework");
    @Autowired
    OperateService operateService;
    /**
     * @Description:通过pk查询操作表一条记录
     * @Param: [pk]
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: wjx
     * @date: 2020/11/16
     */
    @RequestMapping(value = "/selectByPk", method = RequestMethod.POST, name = "主键查询")
    public ResponseTemplate selectByPk(@RequestParam(name="operateId") String pk) {
        //通过pk查询操作表的一条记录
        return operateService.selectByPk(pk);
    }
    /**
     * @Description: 查询所有记录 分页 工种code/名称/线路
     * @Param: [page,limit  typeworkCode/name/line]
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: wjx
     * @date: 2020/11/16
     */
    @RequestMapping(value = "/selectAllData", method = RequestMethod.POST, name = "全表查询")
    public ResponseTemplate selectAllData(String page, String limit, Operate operate) {
        //分页参数为空则赋值0
        if (!StringUtils.isNotEmpty(page)) {
            page = "0";
        }
        if (!StringUtils.isNotEmpty(limit)) {
            limit = "0";
        }
        //查询所有记录 分页
        return operateService.selectAllData(page,limit,operate);
    }
    /**
     *@Description:逻辑删除一条记录
     *@Param: [pk]
     *@return: com.koocloud.electroplatemanage.common.ResponseTemplate
     *@Author: zww
     *@date: 2020/9/30
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST, name = "逻辑删除一条记录")
    public ResponseTemplate delete(@RequestParam(name="operateId") String pk,@RequestParam(name="deleteFlag") String deleteFlag) {
        //逻辑删除一条记录
        return operateService.delete(pk,deleteFlag);
    }

    /**
     *@Description:插入一条记录
     *@Param: [typeWorkVo]
     *@return: com.koocloud.electroplatemanage.common.ResponseTemplate
     *@Author: zww
     *@date: 2020/9/30
     */
    @RequestMapping(value = "/insert", method = RequestMethod.POST, name = "新增一条数据")
    public ResponseTemplate insert(@RequestBody Operate operate) {
        //插入一条记录
        return operateService.insert(operate);
    }
    /**
     *@Description:修改一条记录
     *@Param: [typeWorkVo]
     *@return: com.koocloud.electroplatemanage.common.ResponseTemplate
     *@Author: zww
     *@date: 2020/9/30
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST, name = "修改一条记录")
    public ResponseTemplate update(@RequestBody Operate operate) {
        //修改一条记录
        return operateService.update(operate);
    }
}
